using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using hao_Dto;
using hao_Model;
using hao_Model.Enums;

namespace hao_Reppsitory.Order
{
    /// <summary>
    /// 订单仓储接口
    /// </summary>
    public interface IOrderRepository
    {
        // 基础CRUD
        Task<Guid> AddAsync(hao_Model.Order order);
        Task<hao_Model.Order> GetByIdAsync(Guid id);
        Task<hao_Model.Order> GetByOrderNumberAsync(string orderNumber);
        Task<bool> UpdateAsync(hao_Model.Order order);
        Task<bool> DeleteAsync(Guid id);
        
        // 订单查询
        Task<(List<hao_Model.Order> orders, int total)> SearchOrdersAsync(OrderSearchDto searchDto);
        Task<List<hao_Model.Order>> GetBuyerOrdersAsync(Guid buyerId, OrderStatus? status = null);
        Task<List<hao_Model.Order>> GetSellerOrdersAsync(Guid sellerId, OrderStatus? status = null);
        Task<List<hao_Model.Order>> GetProductOrdersAsync(Guid productId);
        
        // 订单状态管理
        Task<bool> UpdateOrderStatusAsync(Guid orderId, OrderStatus status, Guid? operatorId = null, string reason = null);
        Task<bool> UpdatePaymentStatusAsync(Guid orderId, PaymentStatus status, DateTime? paidAt = null);
        Task<bool> UpdateDeliveryStatusAsync(Guid orderId, DeliveryStatus status, DateTime? shippedAt = null, DateTime? deliveredAt = null);
        
        // 订单统计
        Task<OrderStatisticsDto> GetOrderStatisticsAsync(Guid? userId = null);
        Task<List<OrderDailyStatsDto>> GetDailyOrderStatsAsync(DateTime startDate, DateTime endDate, Guid? userId = null);
        Task<int> GetOrderCountByStatusAsync(OrderStatus status, Guid? userId = null);
        Task<decimal> GetTotalAmountAsync(DateTime? startDate = null, DateTime? endDate = null, Guid? userId = null);
        
        // 业务验证
        Task<bool> CheckOrderOwnershipAsync(Guid orderId, Guid userId);
        Task<bool> CanCancelOrderAsync(Guid orderId);
        Task<bool> CanConfirmOrderAsync(Guid orderId);
        
        // 订单号生成
        Task<string> GenerateOrderNumberAsync();
    }
}